<!DOCTYPE html>
<html class="loginHtml">
<head>
    <meta charset="utf-8">
    <title>注册</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/public.css" media="all"/>
</head>
<body>
<div class="layuimini-main">

    <div lay-filter="userForm" class="layui-form layuimini-form">
		<input id="pageParam" style="display: none" />
        
        <div class="layui-form-item">
            <label class="layui-form-label required">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="userName" required lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label required">密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" required lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">身高(CM)</label>
            <div class="layui-input-block">
                <input type="number" name="height" required lay-verify="required" placeholder="请输入身高" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">体重(KG)</label>
            <div class="layui-input-block">
                <input type="number" name="weight" required lay-verify="required" placeholder="请输入体重" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">低血压值</label>
            <div class="layui-input-block">
                <input type="number" name="hypotensiveValue" required lay-verify="required" placeholder="请输入低血压值" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">高血压值</label>
            <div class="layui-input-block">
                <input type="number" name="hypertensiveValue" required lay-verify="required" placeholder="请输入高血压值" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">血糖值</label>
            <div class="layui-input-block">
                <input type="number" name="bloodGlucoseValue" required lay-verify="required" placeholder="请输入血糖值" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">血脂值</label>
            <div class="layui-input-block">
                <input type="number" name="bloodLipidValue" required lay-verify="required" placeholder="请输入血脂值" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">50米短跑完成秒数</label>
            <div class="layui-input-block">
                <input type="number" name="meterDashTime" required lay-verify="required" placeholder="请输入50米短跑完成秒数" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">引体向上次数</label>
            <div class="layui-input-block">
                <input type="number" name="pullUpTimes" required lay-verify="required" placeholder="请输入引体向上次数" value="" class="layui-input">
            </div>
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label ">俯卧撑次数</label>
            <div class="layui-input-block">
                <input type="number" name="pushUpTimes" required lay-verify="required" placeholder="请输入俯卧撑次数" value="" class="layui-input">
            </div>
        </div> 

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button id="submitButton" class="layui-btn layui-btn-normal" lay-submit lay-filter="save">确认保存</button>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../lib/layui-v2.5.5/layui.js"></script>

<script>
    layui.use(['form', 'table', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(save)', function (data) {
            var formData = data.field;
            layer.confirm('确定要提交吗?', {icon: 1, title: '提示'}, function (index) {
                $.ajax({
                    url: '/api/saveUser',
                    type: 'POST',
                    data: formData,
                    success: function (response) {
                        // 注册成功
                        if(response.code == 0){
                            layer.msg('注册成功!', {
                                icon: 1,
                                time: 2000 // 2秒关闭
                            }, function(){
                                //先得到当前iframe层的索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }else{
                            // 注册失败
                            layer.msg(response.msg, {icon: 2});
                        }
                    }
                });
            });
            return false;
        });
    });
</script>